<template>
	<view style="height: 100%">
		<image class="gg-img" referrerPolicy='no-referrer' :src="bese_info.demand_ad[0]" />
		<!-- 		<swiper class="gg-img" :indicator-dots="true" :circular="true" indicator-color="rgba(255,255,255,.3)"
			indicator-active-color="#fff" :autoplay="true" interval="5000">
			<block v-for="(item, index) in bese_info.demand_ad" :key="index">
				<swiper-item>
					<image class="gg-img" referrerPolicy='no-referrer' :src="item" />
				</swiper-item>
			</block>
		</swiper> -->
		<van-tabs :active="active" @change="onChange1" title-inactive-color="#6B758C" title-active-color="#1050C7"
			color="#1050C7">
			<van-tab title="快速发布"></van-tab>
			<van-tab title="详细发布"></van-tab>
		</van-tabs>
		<!-- 快速发布 -->
		<view class="bgcf pd015" v-if="active == 0">
			<view class="h48 df ac bbf1" hover-class="none" :hover-stop-propagation="false">
				<span class="f14 cf5">*</span>
				<p class="f14 c28">需求说明</p>
			</view>
			<textarea class="db w100 h110 pt15 f14" @input="onInput" data-i="0" :value="val[0]" placeholder-class="cc"
				placeholder="请填写零件名称、数量、材料、要求等信息"></textarea>
			<view class="mt15 df ac sb">
				<image class="w166" src="https://cdn.xtwaixie.com/uploads/20240705/17201796166687dba074393.png"
					mode="widthFix" @tap="upImgArr" data-idx="0"></image>
				<image class="w166" src="https://cdn.xtwaixie.com/uploads/20240705/17201796166687dba0904a2.png"
					mode="widthFix" @tap="upFile" data-idx="0"></image>
			</view>
			<ul class="df ac fw mt8">
				<block v-for="(item, index) in drawing" :key="index">
					<li class="mt8 mr8 img64 pr db">
						<image class="img64" referrerPolicy='no-referrer' :src="img_path + item" />
						<image class="img-del" src="https://wx.xtwaixie.com/img/del.png" @tap="onDel" :data-i="index"
							data-idx="0" />
					</li>
				</block>
			</ul>
			<view class="h44 mt15 bgcf7 df ac pd015" v-if="file_name.lenfth != 0" v-for="(item, index) in file_name"
				:key="index">
				<image class="img16" src="https://wx.xtwaixie.com/img/file.png"></image>
				<p class="ml8 f14 c28 f1">{{ item }}</p>
				<image class="img16" src="https://wx.xtwaixie.com/img/del3.png" @tap="onDelFile" data-idx="0"
					:data-i="index"></image>
			</view>
			<view class="h72 df ac bbf1">
				<van-switch :checked="checked" @change="onChange" size="24px" />
				<view class="f1 ml15" hover-class="none" :hover-stop-propagation="false">
					<p class="f14 c28 db">保密协议</p>
					<p class="f12 cf5 db mt4">需供应商签订保密协议才能查看图纸</p>
				</view>
				<navigator class="f12 c10" url="/pages/about/about?type=9" hover-class="none" open-type="navigate">了解详情
				</navigator>
			</view>
			<view class="df ac sb h48" @tap="onArea" :data-type="0">
				<span class="f14 cf5">*</span>
				<p class="f14 c28">报价截止时间</p>
				<input class="tr f1 ml15 f14 c28" :value="val[1]" placeholder="请选择" placeholder-class="cc" disabled />
				<image class="img14 ml8" src="https://wx.xtwaixie.com/img/more1.png" />
			</view>
		</view>
		<!-- 填写详细信息 -->
		<!-- <view class="" wx:if='{{addinfo_show}}'> -->
		<!-- 详细发布 -->
		<view class="form-tmp" v-if="active == 1">
			<!-- 零件信息  添加零件 -->
			<p class="df ac pd015 h40 f14 c6b">零件信息</p>
			<ul class="db pd015 bgcf mb10" v-if="spare_arr.length != 0">
				<block v-for="(item, index) in spare_arr" :key="index">
					<li class="db pb15">
						<view class="df ac sb h48 bbf1">
							<p class="f16 c28 f600">零件{{ index + 1 }}</p>
							<view class="h48 df ac" @tap="onDelSpare" :data-i="index" v-if="index != 0">
								<image class="img16" src="https://wx.xtwaixie.com/img/del4.png"></image>
								<p class="f14 cf5 ml8">删除零件</p>
							</view>
						</view>
						<view class="df ac sb h48 bbf1">
							<span class="f14 cf5">*</span>
							<p class="f14 c28">零件名称</p>{{mapName}}
							<input class="tr f1 ml15 f14 c28" type="text" @input="onItemInp"
								:value="item.spare_parts_name" :data-i="index" :data-idx="0" placeholder="请填写零件名称"
								placeholder-class="cc" />
						</view>
						<view class="df ac bbf1">
							<view class="df ac h48 f1">
								<span class="f14 cf5">*</span>
								<p class="f14 c28">数量</p>
								<input class="tr f1 ml15 f14 c28" @input="onItemInp" :value="item.number"
									:data-i="index" :data-idx="1" placeholder="请填写数量" placeholder-class="cc"
									type="number" />
							</view>
							<p class="line1"></p>
							<view class="df ac h48 f1">
								<span class="f14 cf5">*</span>
								<p class="f14 c28">单位</p>
								<input class="tr f1 ml15 f14 c28" @input="onItemInp" :value="item.piece" :data-i="index"
									:data-idx="2" placeholder="请填写单位 例:件" placeholder-class="cc" />
							</view>
						</view>
						<view class="df ac sb h48 bbf1">
							<span class="f14 cf5">*</span>
							<p class="f14 c28">材料</p>
							<input class="tr f1 ml15 f14 c28" @input="onItemInp" type="text" :value="item.material"
								:data-i="index" :data-idx="3" placeholder="请填写材料" placeholder-class="cc" />
						</view>
						<view class="df ac sb h48 bbf1" @tap.native="onArea($event, { type: 4 })" :data-type="4"
							:data-i="index">
							<p class="f14 c28">工艺</p>
							<input class="tr f1 ml15 f14 c28" placeholder="请选择"
								:value="item.machining_name.split(' ').join('、')" @click="toggle('bottom')"
								:data-type="4" :data-i="index" placeholder-class="cc" disabled />
							<image class="more ml8" src="https://wx.xtwaixie.com/img/more.png"></image>
							<!-- <p>{{item.machining_name}}</p> -->
						</view>
						<view class="df ac sb h48 bbf1">
							<p class="f14 c28">备注</p>
							<input class="tr f1 ml15 f14 c28" @input="onItemInp" :value="item.remarks" :data-i="index"
								:data-idx="4" placeholder="请填写备注信息" placeholder-class="cc" />
						</view>
						<view class="mt15 df ac sb">
							<image class="w166" src="https://wx.xtwaixie.com/img/upimg1.png" mode="widthFix"
								@tap="upImgArr" :data-i="index" data-idx="1"></image>
							<image class="w166" src="https://wx.xtwaixie.com/img/upfile1.png" mode="widthFix"
								@tap="upFile" :data-i="index" data-idx="1"></image>
						</view>
						<ul class="df ac fw mt15" v-if="item.drawing.length != 0">
							<block v-for="(it, index1) in item.drawing" :key="index1">
								<li class="mb8 mr8 img64 pr db">
									<image class="img64" referrerPolicy='no-referrer' :src="img_path + it" />
									<image class="img-del" src="https://wx.xtwaixie.com/img/del.png" @tap="onDel"
										:data-i="index" data-idx="1" />
								</li>
							</block>
						</ul>
						<view class="h44 mt8 bgcf7 df ac pd015" v-if="item.file_name.length != 0"
							v-for="(it, index1) in item.file_name" :key="index1">
							<image class="img16" src="https://wx.xtwaixie.com/img/file.png"></image>
							<p class="ml8 f14 c28 f1">{{ it }}</p>
							<image class="img16" src="https://wx.xtwaixie.com/img/del3.png" @tap="onDelFile"
								data-idx="1" :data-i="index"></image>
						</view>
					</li>
				</block>
			</ul>
			<view class="df ac jc h48 bgcf" @tap="onAddSpare">
				<image class="img24" src="https://wx.xtwaixie.com/img/add3.png"></image>
				<p class="f16 c10 ml4">添加零件</p>
			</view>
			<!-- 交付信息 -->
			<p class="df ac pd015 h40 f14 c6b">交付信息</p>
			<ul class="db bgcf pd015">
				<li class="df ac sb h48 bbf1" @tap.native="onArea($event, { type: 1 })" :data-type="1">
					<span class="f14 cf5">*</span>
					<p class="f14 c28">采购区域</p>
					<input class="tr f1 ml15 f14 c28" :value="val[2]" placeholder="请选择" placeholder-class="cc"
						disabled />
					<image class="img14 ml8" src="https://wx.xtwaixie.com/img/more1.png" />
				</li>
				<li class="df ac sb h48 bbf1" @tap.native="onArea($event, { type: 2 })" :data-type="2">
					<span class="f14 cf5">*</span>
					<p class="f14 c28">交货地</p>
					<input class="tr f1 ml15 f14 c28" :value="val[3][0] + val[3][1]" placeholder="请选择"
						placeholder-class="cc" disabled />
					<image class="img14 ml8" src="https://wx.xtwaixie.com/img/more1.png" />
				</li>
				<li class="df ac h48 bbf1">
					<span class="f14 cf5">*</span>
					<p class="f14 c28 f1">报价是否含税</p>
					<ul class="df">
						<li class="df ac ml24" @tap.native="onRadio($event, { i: '0', act: '1' })" data-i="0"
							data-act="1">
							<image class="img18" referrerPolicy='no-referrer'
								:src="radio[0] == 1 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
							</image>
							<p class="f14 c28 ml8">含税</p>
						</li>
						<li class="df ac ml24" @tap.native="onRadio($event, { i: '0', act: '2' })" data-i="0"
							data-act="2">
							<image class="img18" referrerPolicy='no-referrer'
								:src="radio[0] == 2 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
							</image>
							<p class="f14 c28 ml8">不含税</p>
						</li>
					</ul>
				</li>
				<li class="df ac h48 bbf1">
					<span class="f14 cf5">*</span>
					<p class="f14 c28 f1">报价是否含运费</p>
					<ul class="df">
						<li class="df ac ml24" @tap.native="onRadio($event, { i: '1', act: '1' })" data-i="1"
							data-act="1">
							<image class="img18" referrerPolicy='no-referrer'
								:src="radio[1] == 1 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
							</image>
							<p class="f14 c28 ml8">含运费</p>
						</li>
						<li class="df ac ml24" @tap.native="onRadio($event, { i: '1', act: '2' })" data-i="1"
							data-act="2">
							<image class="img18" referrerPolicy='no-referrer'
								:src="radio[1] == 2 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
							</image>
							<p class="f14 c28 ml8">不含运费</p>
						</li>
					</ul>
				</li>
				<li class="df ac h48 bbf1">
					<span class="f14 cf5">*</span>
					<p class="f14 c28 f1">付款方式</p>
					<ul class="df">
						<li class="df ac ml24" @tap.native="onRadio($event, { i: '2', act: '1' })" data-i="2"
							data-act="1">
							<image class="img18" referrerPolicy='no-referrer'
								:src="radio[2] == 1 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
							</image>
							<p class="f14 c28 ml8">协商</p>
						</li>
						<li class="df ac ml24" @tap.native="onRadio($event, { i: '2', act: '2' })" data-i="2"
							data-act="2">
							<image class="img18" referrerPolicy='no-referrer'
								:src="radio[2] == 2 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
							</image>
							<p class="f14 c28 ml8">有预付</p>
						</li>
					</ul>
				</li>
				<li class="df ac sb h48 bbf1" :data-type="3" v-if="radio[2] == 2">
					<span class="f14 cf5">*</span>
					<p class="f14 c28">预付比列</p>
					<input class="tr f1 ml15 f14 c28" :value="val[9]" @input="onInput" data-i="9" placeholder="请填写预付比列"
						placeholder-class="cc" />
					<p class="f14 c28">%</p>
				</li>
				<li class="df ac h48 bbf1">
					<span class="f14 cf5">*</span>
					<p class="f14 c28 f1">交货时间</p>
					<ul class="df">
						<li class="df ac ml24" @tap.native="onRadio($event, { i: '3', act: '1' })" data-i="3"
							data-act="1">
							<image class="img18" referrerPolicy='no-referrer'
								:src="radio[3] == 1 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
							</image>
							<p class="f14 c28 ml8">协商</p>
						</li>
						<li class="df ac ml24" @tap.native="onRadio($event, { i: '3', act: '2' })" data-i="3"
							data-act="2">
							<image class="img18" referrerPolicy='no-referrer'
								:src="radio[3] == 2 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
							</image>
							<p class="f14 c28 ml8">选取时间</p>
						</li>
					</ul>
				</li>
				<li class="df ac sb h48 bbf1" @tap.native="onArea($event, { type: 3 })" :data-type="3"
					v-if="radio[3] == 2">
					<span class="f14 cf5">*</span>
					<p class="f14 c28">选取时间</p>
					<input class="tr f1 ml15 f14 c28" :value="val[4]" placeholder="请选择" placeholder-class="cc"
						disabled />
					<image class="img14 ml8" src="https://wx.xtwaixie.com/img/more1.png" />
				</li>
				<view class="h72 df ac bbf1">
					<van-switch :checked="checked" @change="onChange" size="24px" />
					<view class="f1 ml15" hover-class="none" :hover-stop-propagation="false">
						<p class="f14 c28 db">保密协议</p>
						<p class="f12 cf5 db mt4">需供应商签订保密协议才能查看图纸</p>
					</view>
					<navigator class="f12 c10" url="/pages/about/about?type=9" hover-class="none" open-type="navigate">
						了解详情</navigator>
				</view>
				<li class="df ac sb h48" @tap.native="onArea($event, { type: 0 })" :data-type="0">
					<span class="f14 cf5">*</span>
					<p class="f14 c28">报价截止时间</p>
					<input class="tr f1 ml15 f14 c28" :value="val[1]" placeholder="请选择" placeholder-class="cc"
						disabled />
					<image class="img14 ml8" src="https://wx.xtwaixie.com/img/more1.png" />
				</li>
			</ul>
		</view>
		<!-- <view class="df ac jc h48 mt10 bgcf" bindtap='onInfoShow'>
	<p class="f14 c10">{{addinfo_show?'收起详细信息':'填写详细信息'}}</p>
	<image class="down1 ml6" src="{{addinfo_show?'../../img/down1.png':'../../img/down2.png'}}"></image>
</view> -->
		<!-- 企业信息 -->
		<ul class="db bgcf pd015 mt10">
			<li class="df ac h48 bbf1">
				<span class="f14 cf5">*</span>
				<p class="f14 c28 f1">联系信息</p>
				<ul class="df">
					<li class="df ac ml24" @tap.native="onRadio($event, { i: '4', act: '0' })" data-i="4" data-act="0">
						<image class="img18" referrerPolicy='no-referrer'
							:src="radio[4] == 0 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
						</image>
						<p class="f14 c28 ml8">直接联系</p>
					</li>
					<li class="df ac ml24" @tap.native="onRadio($event, { i: '4', act: '1' })" @click="showBj"
						data-i="4" data-act="1">
						<image class="img18" referrerPolicy='no-referrer'
							:src="radio[4] == 1 ? 'https://wx.xtwaixie.com/img/sel1.png' : 'https://wx.xtwaixie.com/img/sel2.png'">
						</image>
						<p class="f14 c28 ml8">报价后可见</p>
					</li>
				</ul>
			</li>
			<li class="df ac sb h48 bbf1">
				<span class="f14 cf5">*</span>
				<p class="f14 c28">企业名称</p>
				<input class="tr f1 ml15 f14 c28" @input="onInput" data-i="5" :value="val[5]" placeholder="请填写贵公司全称"
					placeholder-class="cc" />
				<!-- 	<input class="tr f1 ml15 f14 c28" @input="onInputYY" data-i="5" :value="val[5]" placeholder="请填写贵公司全称"
					placeholder-class="cc" />
				<view class="passed">
					<image @click.stop="gongS" v-if="!isPassed" style="width: 100%;height: 100%;"
						src="@/static/icon/not_passed.png" mode="widthFix"></image>
					<image @click.stop="gongS" v-else style="width: 100%;height: 100%;" src="@/static/icon/passed.png"
						mode="widthFix">
					</image>
					<view v-show="gongShow" class="pd_tab">
						<image v-if="isPassed" src="../../static/已通过.png" mode="aspectFit"></image>
						<image v-else src="../../static/未通过.png" mode="aspectFit"></image>
					</view>
				</view> -->
			</li>
			<view class="search-D" v-if="SySeach==true">
				<view @click="SySeach=false" v-if="Result" class="" style="padding: 6px 0 6px 6px;"> 关闭 </view>
				<view v-for="(item,index) in Result" :key="index" class="">
					<view class="titleName" @click="selectName(item.Name)">
						{{item.Name}}
					</view>
				</view>
			</view>
			<li class="df ac sb h48 bbf1">
				<span class="f14 cf5">*</span>
				<p class="f14 c28">联系人</p>
				<input class="tr f1 ml15 f14 c28" @input="onInput" data-i="6" :value="val[6]" placeholder="联系人名称"
					placeholder-class="cc" />
			</li>
			<li class="df ac sb h48 bbf1">
				<span class="f14 cf5">*</span>
				<p class="f14 c28">联系方式</p>
				<input class="tr f1 ml15 f14 c28" @input="onInput" data-i="7" :value="val[7]" type="number"
					placeholder="手机号" placeholder-class="cc" />
			</li>
			<li class="df ac sb h48">
				<p class="f14 c28">
					<image src="@/static/success.png" mode="widthFix" style="height: 50rpx;width: 50rpx;"></image>
				</p>
				<input class="tr f1 ml15 f14 c28" @input="onInput" data-i="8" :value="val[8]" placeholder="社交账号"
					placeholder-class="cc" />
			</li>
		</ul>
		<view class="agreementBox">
			<navigator class="f14 c10" url="/pages/about/about?type=12" hover-class="none" open-type="navigate"
				style="line-height: 40rpx;font-size: 26rpx !important;">《用户服务协议》</navigator>
			<navigator class="f14 c10" url="/pages/about/about?type=2" hover-class="none" open-type="navigate"
				style="line-height: 40rpx;font-size: 26rpx !important;">《隐私政策》</navigator>
		</view>
		<view class="pd715 bgcf pob">
			<button class="sub" @tap="onSub">{{ id ? '编辑' : '提交' }}发布</button>
		</view>
		<van-popup :show="show_list[0]" round position="bottom">
			<!-- <van-datetime-picker type="date" value="{{ currentDate }}" bind:cancel="onClose" bind:confirm='confirm' min-date="{{ minDate }}" formatter="{{ formatter }}" /> -->
			<van-picker :columns="times" @cancel="onClose" @confirm="confirm" :show-toolbar="true" />
		</van-popup>
		<van-popup :show="show_list[1]" round @close="onClose" position="bottom">
			<van-picker :columns="region" @cancel="onClose" @confirm="confirm" value-key="name" :show-toolbar="true" />
		</van-popup>

		<!-- <van-popup :show="show_list[2]" round @close="onClose" position="bottom">
			<van-area :area-list="areaList" @confirm="confirm" @cancel="onClose" columns-num="2" />
		</van-popup> -->

		<van-popup :show="show_list[2]" round @close="onClose" position="bottom">
			<van-cascader :options="options" v-if="show_list[2]" :value="val[3]" title="请选择交货地" active-color="#1050c7"
				@change="changeArea" @close="onClose" @finish="onFinish" />
		</van-popup>

		<van-popup :show="show_list[3]" round position="bottom">
			<van-datetime-picker type="date" :value="currentDate" @cancel="onClose" @confirm="confirm"
				:min-date="minDate" :formatter="formatter" />
		</van-popup>
		<!-- 		<van-popup :show="show_list[4]" round @close="onClose" position="bottom">
			<van-picker :columns="bese_info.machining" show-toolbar @confirm="confirmType" value-key="name"
				@cancel="onClose" />
		</van-popup> -->
		<van-popup :show="show_list[4]" @close="onClose" position="bottom" round>
			<view class="" style="width: 100vw;height: 840rpx;border-radius: 0; overflow: visible;">
				<technology :lists="bese_info.machining" v-if="show_list[4]" @agree="agree" :status="false"
					:technologyList='technologyList' />
			</view>
		</van-popup>

		<!-- <uni-popup  ref="popup" background-color="#fff" @change="change" position="bottom" round>
					<view class="" style="width: 100vw;height: 840rpx;border-radius: 0; overflow: visible;">
						<technology :lists="bese_info.machining" v-if="show_list[4]" @agree="agree" :status="false"
							:technologyList='technologyList' />
							</view>
					
		</uni-popup> -->

		<van-popup :show="showTips" @close="onClose" custom-style='background:#00000000;'>
			<image src="https://cdn.xtwaixie.com/uploads/20240415/1713170369661ce7c10e9d1.gif" mode="widthFix"
				style="width: 500rpx;padding-bottom: 600rpx;"></image>
		</van-popup>
		<van-popup :show="showWechat" z-index='10000' :close-on-click-overlay='false'
			custom-style='background:rgba(0,0,0,0);'>
			<view class="popupBox">
				<image referrerPolicy='no-referrer' :src="getImgSrc(inquiry_qr_code)" :show-menu-by-longpress="true"
					mode="widthFix" class="popupImg"></image>
				<image src="https://wx.xtwaixie.com/img/bh.png" class="popupOut" @click="showWechat = false"></image>
			</view>
		</van-popup>
		<!-- 客服弹框 -->
		<!--        <view class="kfs-box kfs-box1">
            <image class="kfs" src="https://wx.xtwaixie.com/img/kf3.png" @tap="onKfShow"></image>
            <view :class="'kfs-cont ' + (kf_show ? 'kf-out' : 'kf-in')">
                <view class="df ac h28 ml4">
                    <button class="add-but" v-if="kf_show" open-type="contact">咨询</button>
                    <p class="f12 cf ml8">采购询价 图纸问题 接单服务</p>
                </view>
            </view>
        </view> -->
		<!-- 		<image src="https://cdn.xtwaixie.com/uploads/20240415/1713170494661ce83e6e389.png" mode="aspectFit" style="position: fixed;z-index: 9999;right: 24rpx;width: 88rpx;height: 88rpx;bottom: 170rpx;" @tap="showWechat = true"></image> -->
		<toast :value='showToast' title='微信禁止电脑端小程序上传文件' :ifHtml='true'
			content='1、可将文件发送至“文件传输助手”微信，通过手机上传文件发布。<br/>2、不上传文件发布。后添加微信xtwaixie，平台补充上传图纸文件。' btnText='知道了'
			@change='showToast=false' />
		<van-popup :show="showPopup" z-index='10000' :close-on-click-overlay='false'
			custom-style='background:rgba(0,0,0,0);'>
			<view class="xpopupBox">
				<view class="xloginPopup">
					<view class=""> 请尽量提供清晰的图纸和明确的要求，以便工厂准确报价 </view>
					<view class="" @click="showPopup = false"> 好的 </view>
				</view>
			</view>
		</van-popup>
		<van-dialog use-slot title="是否自动获取定位" :show="showYY " show-cancel-button confirm-button-open-type="getuserinfoY"
			@close="YYonClose" @getuserinfo="getuserinfoY">
		</van-dialog>
	</view>
</template>
<script>
	import {
		verifyPhoneNumber
	} from "@/utils/util"
	import areaList from '../../utils/area';
	const http = require('../../utils/http');
	import util from '../../utils/util';
	import {
		toast
	} from "@/component/toast.vue"
	// import UniPopup from "@/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue"
	import {
		technology
	} from "@/component/technology.vue"
	var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
	const options = [{
			text: '浙江省',
			value: '330000',
			children: [{
				text: '杭州市',
				value: '330100'
			}],
		},
		{
			text: '江苏省',
			value: '320000',
			children: [{
				text: '南京市',
				value: '320100'
			}],
		},
	];
	const fieldNames = {
		// 换成后端返回的你需要的对应字段
		text: 'name',
		value: 'id',
		children: 'children'
	};
	export default {
		components: {
			toast,
			technology
		},
		data() {
			return {
				Result: [],
				type: 'center',
				code: '',
				options: [],
				qqMapWX: '',
				mapName: '',
				technologyList: [],
				showPopup: false,
				active: 0,
				val: ['', '15天后', '', ['', ''], '', '', '', '', '', ''],
				img_path: '',
				showToast: false,
				region: [{
					name: '全国',
					id: 1
				}, {
					name: '就近优先',
					id: 2
				}, {
					name: '珠三角',
					id: 3
				}, {
					name: '长三角',
					id: 4
				}],
				timer: null,
				times: ['7天后', '15天后', '30天后'],
				show_list: [false, false, false, false, false],
				areaList: areaList.areaList,
				checked: false,
				currentDate: new Date().getTime(),
				minDate: new Date().getTime(),
				formatter(type, value) {
					if (type === 'year') {
						return `${value}年`;
					}
					if (type === 'month') {
						return `${value}月`;
					}
					return value;
				},
				addinfo_show: false,
				kf_show: false,
				showWechat: false,
				inquiry_qr_code: '',
				spare_arr: [{
					spare_parts_name: '',
					number: '',
					material: '',
					piece: '',
					machining_id: [],
					machining_name: '',
					remarks: '',
					drawing: [],
					file: [],
					file_name: []
				}],
				bese_info: {
					demand_ad: [],
					machining: ''
				},
				drawing: [],
				//图纸
				procurement_area_id: '',
				procurement_area_name: '',
				file: [],
				file_name: [],
				add_idx: '',
				radio: [0, 0, 0, 0, 0],
				id: '',
				lock: false,
				act: '',
				it: '',
				showTips: false,
				showYY: false,
				isDisabled: false,
				callback: null,
				isPassed: false,
				SySeach: false,
				gongShow: false
			};
		}
		/**
		 * 生命周期函数--监听页面加载
		 */
		,
		onLoad(options) {
			this.qqMapWX = new QQMapWX({
				key: "XUDBZ-3OVAL-KWEPB-MXU6W-KW4XK-6WBHF",
			});
			console.log(areaList.areaList, 'areaListareaList')
			this.callback = verifyPhoneNumber(false,false)
			if (!this.callback){
				http.request('demand/access')
			} 
			this.getBase();
			this.setData({
				img_path: http.img_path,
				id: options.id ? options.id : ''
			});
			if (options.id) {
				this.getInfo();
				uni.setNavigationBarTitle({
					title: '编辑需求'
				});
			}
			let token = uni.getStorageSync('token');
			if (token) {
				this.getUserInfo();
			}

			this.getArea(1)
			// this.getLocation()
		},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload() {
			clearTimeout(this.callback)
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady() {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow() {
			http.request('base/configData').then((res) => {
				this.inquiry_qr_code = res.data.inquiry_qr_code
			}).catch((res) => {
				uni.showToast({
					title: res.message,
					icon: 'none'
				});
			});
			let demandDate = uni.getStorageSync('demandData');
			if (demandDate) {
				console.log(demandDate);
				this.setData({
					end_at_id: this.val[1] == '7天后' ? 1 : this.val[1] == '15天后' ? 2 : this.val[1] == '30天后' ?
						3 : '',
					['val[1]']: demandDate.end_at_id == 1 ? '7天后' : demandDate.end_at_id == 2 ? '15天后' : demandDate
						.end_at_id == 3 ? '30天后' : '',
					active: demandDate.type == 2 ? 0 : demandDate.type,
					['val[9]']: demandDate.proportion,
					[`val[0]`]: demandDate.spare_parts_name,
					drawing: demandDate.drawing,
					file_name: demandDate.file_name,
					file: demandDate.file,
					checked: demandDate.is_secrecy == 1 ? true : false,
					spare_arr: demandDate.parts,
					[`val[2]`]: demandDate.procurement_area_name,
					procurement_area_id: demandDate.procurement_area_id,
					[`val[3][0]`]: demandDate.province,
					[`val[3][1]`]: demandDate.city,
					[`radio[0]`]: demandDate.is_tax_include,
					[`radio[1]`]: demandDate.is_freight,
					[`radio[2]`]: demandDate.is_budget,
					[`radio[3]`]: demandDate.delivery_type,
					[`val[4]`]: demandDate.delivery_at,
					[`val[5]`]: demandDate.company,
					[`val[6]`]: demandDate.username,
					[`val[7]`]: demandDate.mobile,
					[`val[8]`]: demandDate.email,
					[`radio[4]`]: demandDate.is_quotation
				});
				uni.removeStorageSync('demandData')
			}
			this.setData({
				lock: false
			});
		},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload() {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh() {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom() {},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage() {},
		methods: {
			selectName(name) {
				this.SySeach = false
				this.isPassed = true
				this.setData({
					[`val[${5}]`]: name
				});
			},
			gongS() {
				this.gongShow = !this.gongShow;
			},
			onInputYY(e) {
				console.log(e.detail.value)
				if (this.SySeach = true) {
					this.isPassed = false;
				}
				const val = e.detail.value;
				const i = e.currentTarget.dataset.type;
				this.setData({
					[`val[${i}]`]: val,
				});
				// 清除之前的定时器
				if (this.timer) {
					clearTimeout(this.timer);
				}
				// 设置新的定时器，延迟500毫秒后执行
				this.timer = setTimeout(() => {
					if (val.length >= 4) {
						this.SySeach = true;
						http.request("user/qichacha", {
							name: val
						}).then((res) => {
							console.log(res.data.Result.Data);
							this.Result = res.Result.Data;
							console.log(res.Result.Data);
						}).catch((err) => {
							this.Result = err.Result.Data;
							console.log(err.Result.Data);
						});
					} else {
						this.isPassed = false;
						this.SySeach = false
					}
				}, 500); // 延迟时间可以根据需要调整
			},
			getArea(id, index) {
				let data = {
					pid: id
				};
				http.request('base/region', data).then((res) => {
					if (id === 1) {
						res.data.map((item, idx) => {
							if (idx != 0) {
								this.options.push({
									value: idx - 1,
									...item,
									text: item.region_name,
									children: []
								})
							}

						})
					}
				}).catch((res) => {
					uni.showToast({
						title: res.message,
						icon: 'none'
					});
				});
			},
			changeArea(e) {
				console.log(e)

				http.request('base/region', {
					pid: e.detail.selectedOptions[0].region_id
				}).then((res) => {
					let list = []
					res.data.map((item, idx) => {
						list.push({
							value: item.region_id,
							...item,
							text: item.region_name,
						})
					})
					// this.setData({
					// 	[`options${index}.children`]:list
					// })
					this.options = this.options.map((item, i) => {
						if (i == e.detail.value) {
							item.children = list
						}
						return item
					})
					console.log(list, this.options[e.detail.value])
				})
				// this.getArea(e.detail.selectedOptions[0].region_id,e.detail.value)
			},
			onFinish(e) {
				const {
					selectedOptions,
					value
				} = e.detail;
				const fieldValue = selectedOptions
					.map((option) => option.text || option.name)
					.join('/');


				this.setData({
					[`val[3]`]: [selectedOptions[0].region_name, selectedOptions[1].region_name]
				});
				// this.()
				// console.log(e)
				this.onClose();
			},
			getuserinfoY(event) {
				console.log(event.detail);
				console.log(2);
				// this.getLocation()
			},
			YYonClose(event) {
				console.log(event);
				if (event.detail == 'confirm') {
					// 处理确认逻辑
					this.showYY = false
					this.getLocation()
					this.showTips = false
					this.setData({
						show_list: [false, false]
					});
					console.log(1);
				} else if (event.detail == 'cancel') {
					// 处理取消逻辑
					console.log(2);
				}
			},
			showBj() {
				// 获取用户的订阅状态
				const popupTime = uni.getStorageSync('popupTime')
				// 如果用户未订阅，则弹出订阅消息提示
				if (!popupTime) {
					uni.requestSubscribeMessage({
						tmplIds: ['5SQbIg20NgfTt5-y7GY8BRzxqvrinsp-GnKzQIPcNPo'],
						complete(res) {
							// 用户同意订阅后，将订阅状态存储在本地
							if (res['5SQbIg20NgfTt5-y7GY8BRzxqvrinsp-GnKzQIPcNPo'] == 'accept') {
								uni.setStorageSync('popupTime', new Date().getTime())
							}
						}
					})
				}
			},
			agree(id, name) {
				console.log(id, name);
				let i = this.add_idx;
				this.setData({
					[`spare_arr[${i}].machining_id`]: id,
					[`spare_arr[${i}].machining_name`]: name.join(' '),
				});
				this.onClose();
			},
			getLocation() {
				return new Promise((resolve, reject) => {
					let that = this;
					uni.getLocation({
						success(res) {
							let latitude = res.latitude;
							let longitude = res.longitude;
							that.qqMapWX.reverseGeocoder({
								location: {
									latitude: latitude,
									longitude: longitude
								},
								success(res) {
									console.log(1);
									let val = res.result.address_component.city;
									let val1 = res.result.address_component.province;
									that.setData({
										top_area: [val1, val],
										[`val[3]`]: [val1, val],
									});
								},
								fail(err) {
									console.debug(err);
								}
							});
						},
					});
				});
			},
			// 提交发布
			onSub() {
				this.callback = verifyPhoneNumber()
				if (this.callback) return
				if (this.active == 0) {
					if (this.val[0].trim() == '') {
						uni.showToast({
							title: "请输入需求说明",
							icon: "none"
						})
						return
					}
				} else {
					let result = false
					result = this.spare_arr.every(res => {
						return res.spare_parts_name.trim() != ''
					})
					if (!result) {
						uni.showToast({
							title: "请填写零件名称",
							icon: "none"
						})
						return
					}
					let result1 = false
					result1 = this.spare_arr.every(res => {
						return res.number.trim() != ''
					})
					if (!result1) {
						uni.showToast({
							title: "请填写数量",
							icon: "none"
						})
						return
					}
					let result2 = false
					result2 = this.spare_arr.every(res => {
						return res.piece.trim() != ''
					})
					if (!result2) {
						uni.showToast({
							title: "请填写单位",
							icon: "none"
						})
						return
					}
					let result3 = false
					result3 = this.spare_arr.every(res => {
						return res.material.trim() != ''
					})
					if (!result3) {
						uni.showToast({
							title: "请填写材料",
							icon: "none"
						})
						return
					}
					if (this.val[2] == '') {
						uni.showToast({
							title: "请选择采购区域",
							icon: "none"
						})
						return
					}
					if ((this.val[3][0] + this.val[3][1]) == '') {
						uni.showToast({
							title: "请选择交货地",
							icon: "none"
						})
						return
					}
					if (this.radio[0] == 0) {
						uni.showToast({
							title: "请选择报价是否含税",
							icon: "none"
						})
						return
					}
					if (this.radio[1] == 0) {
						uni.showToast({
							title: "请选择报价是否含运费",
							icon: "none"
						})
						return
					}
					if (this.radio[2] == 0) {
						uni.showToast({
							title: "请选择付款方式",
							icon: "none"
						})
						return
					}
					if (this.radio[2] == 2) {
						if (this.val[9].trim() == '') {
							uni.showToast({
								title: "请填写预付比列",
								icon: "none"
							})
							return
						}
					}
					if (this.radio[3] == 0) {
						uni.showToast({
							title: "请选择交货时间",
							icon: "none"
						})
						return
					}
					if (this.radio[3] == 2) {
						if (this.val[4].trim() == '') {
							uni.showToast({
								title: "请选取时间",
								icon: "none"
							})
							return
						}
					}
				}
				if (this.val[1] == '') {
					uni.showToast({
						title: "请选择报价截止时间",
						icon: "none"
					})
					return
				}
				if (this.val[5].trim() == '') {
					uni.showToast({
						title: "请输入企业名称",
						icon: "none"
					})
					return
				}
				if (this.val[6].trim() == '') {
					uni.showToast({
						title: "请填写联系人",
						icon: "none"
					})
					return
				}
				if (this.val[7].trim() == '') {
					uni.showToast({
						title: "请填写联系方式",
						icon: "none"
					})
					return
				}
				let phoneReg = /^1\d{10}$/;
				if (!phoneReg.test(this.val[7])) {
					uni.showToast({
						title: '填写手机号位数不对',
						icon: 'none'
					})
					return
				}
				let token = uni.getStorageSync('token')
				if (!token) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return
				}
				if (this.lock) {
					uni.showToast({
						title: '提交，请稍等',
						icon: 'none'
					});
					return false;
				}
				let data = {
					spare_parts_name: this.val[0],
					drawing: this.drawing,
					file: this.file,
					is_secrecy: this.checked ? 1 : 2,
					// end_at: this.data.val[1],
					procurement_area_id: this.procurement_area_id,
					procurement_area_name: this.val[2],
					province: this.val[3][0],
					city: this.val[3][1],
					is_tax_include: this.radio[0],
					is_freight: this.radio[1],
					is_budget: this.radio[2],
					delivery_type: this.radio[3],
					delivery_at: this.val[4],
					company: this.val[5],
					username: this.val[6],
					mobile: this.val[7],
					email: this.val[8],
					parts: this.spare_arr,
					file_name: this.file_name,
					proportion: this.val[9],
					type: this.active == 0 ? 2 : this.active,
					end_at_id: this.val[1] == '7天后' ? 1 : this.val[1] == '15天后' ? 2 : this.val[1] == '30天后' ? 3 : '',
					is_quotation: this.radio[4]
				};
				if (this.id) {
					data.id = this.id;
				}
				if (token) {
					this.setData({
						lock: true
					});
				} else {
					uni.setStorageSync("demandData", data)
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return
				}
				// const self = this
				// uni.requestSubscribeMessage({
				// 	tmplIds: ['5SQbIg20NgfTt5-y7GY8BRzxqvrinsp-GnKzQIPcNPo',
				// 		'djlfsr2DN_0NN4zBXQ6s5Admjh5vUTz0HLw3wu5BB1o'
				// 	],
				// 	complete() {
				// 		self.submit(data)
				// 		self.showTips = false
				// 	}
				// })
				const self = this
				uni.requestSubscribeMessage({
					tmplIds: ['5SQbIg20NgfTt5-y7GY8BRzxqvrinsp-GnKzQIPcNPo'],
					complete() {
						self.submit(data)
						self.showTips = false
					}
				})
			},
			submit(data) {
				http.request('demand/demandAdd', data).then((res) => {
					http.request('demand/getIp', {
						type: 5,
						id: res.data.id
					}).then(res => {})
					setTimeout(() => {

						this.setData({
							lock: false
						});
						uni.reLaunch({
							url: '/pages/demand/subSuccess?fromPage=/pages/demand/subSuccess'
						});
					}, 500);
				}).catch((res) => {
					this.setData({
						lock: false
					});
					uni.showToast({
						title: res.message,
						icon: 'none'
					});
				});
			},
			onChange1(event) {
				this.setData({
					active: event.detail.index
				});
			},
			// 获取个人信息
			getUserInfo() {
				http.request('user/userInfo').then((res) => {
					if (res.data.userInfo.company == '') {
						console.log('111');
					} else {
						console.log('222');
						this.setData({
							[`val[5]`]: res.data.userInfo.company,
							[`val[6]`]: res.data.userInfo.username,
							[`val[7]`]: res.data.userInfo.company_tel,
							[`val[8]`]: res.data.userInfo.email
						});
					}
				}).catch((res) => {
					uni.showToast({
						title: res.message,
						icon: 'none'
					});
				});
			},
			//  添加零件
			onAddSpare() {
				let data = {
					spare_parts_name: '',
					number: '',
					material: '',
					piece: '',
					machining_id: '',
					machining_name: '',
					remarks: '',
					drawing: [],
					file: [],
					file_name: []
				};
				this.spare_arr.push(data);
				this.setData({
					spare_arr: this.spare_arr
				});
			},
			// 删除零件
			onDelSpare(e) {
				let i = e.currentTarget.dataset.i;
				this.spare_arr.splice(i, 1);
				this.setData({
					spare_arr: this.spare_arr
				});
			},
			//  上传照片
			upImgArr(e) {
				let i = e.currentTarget.dataset.i;
				let idx = e.currentTarget.dataset.idx;
				let that = this;
				uni.chooseImage({
					count: '9',
					sizeType: ['original'],
					success(res) {
						uni.showLoading({
							title: '上传中'
						});
						for (let j = 0; j < res.tempFilePaths.length; j++) {
							http.upLoadFile('base/uploadImg', 'image', res.tempFilePaths[j], {}).then((res) => {
								if (idx == 1) {
									that.spare_arr[i].drawing.push(res.data.url);
									that.setData({
										[`spare_arr[${i}].drawing`]: that.spare_arr[i].drawing
									});
								} else {
									that.drawing.push(res.data.url);
									that.setData({
										drawing: that.drawing
									});
								}
								uni.hideLoading();
							}).catch((res) => {
								uni.hideLoading();
								uni.showToast({
									title: res.message,
									icon: 'none'
								});
							});
						}
					},
					fail() {
						uni.hideLoading();
					}
				});
			},
			// 删除图片
			onDel(e) {
				let i = e.currentTarget.dataset.i;
				let ins = e.currentTarget.dataset.ins;
				let idx = e.currentTarget.dataset.idx;
				if (idx == 1) {
					this.spare_arr[i].drawing.splice(ins, 1);
					this.setData({
						[`spare_arr[${i}].drawing`]: this.spare_arr[i].drawing
					});
				} else {
					this.drawing.splice(i, 1);
					this.setData({
						drawing: this.drawing
					});
				}
			},
			// 上传文件
			upFile(e) {
				let i = e.currentTarget.dataset.i;
				let idx = e.currentTarget.dataset.idx;
				let that = this;
				wx.getSystemInfo({
					success: (res) => {
						if (res.platform == 'android' || res.platform == 'ios') {
							uni.chooseMessageFile({
								count: 9,
								type: 'file',
								success(res) {
									uni.showLoading({
										title: '上传中'
									});
									let up_length = 0;
									let list_length = res.tempFiles.length;
									for (let j = 0; j < res.tempFiles.length; j++) {
										let tempFiles = res.tempFiles[j];
										http.upLoadFile('base/getFile', 'file', tempFiles.path, {})
											.then((res) => {
												up_length = up_length + 1;
												if (idx == 1) {
													that.spare_arr[i].file.push(res.data.file);
													that.spare_arr[i].file_name.push(tempFiles
														.name);
													that.setData({
														[`spare_arr[${i}].file`]: that
															.spare_arr[i].file,
														[`spare_arr[${i}].file_name`]: that
															.spare_arr[i].file_name
													});
												} else {
													that.file.push(res.data.file);
													that.file_name.push(tempFiles.name);
													that.setData({
														file: that.file,
														file_name: that.file_name
													});
												}
												if (up_length == list_length) {
													uni.hideLoading();
												}
											}).catch((res) => {
												uni.hideLoading();
												uni.showToast({
													title: res.message,
													icon: 'none'
												});
											});
									}
								},
								fail(res) {
									uni.hideLoading();
								}
							});
						} else {
							this.showToast = true
						}
					}
				});
			},
			// 删除文件
			onDelFile(e) {
				let i = e.currentTarget.dataset.i;
				let ins = e.currentTarget.dataset.ins;
				let idx = e.currentTarget.dataset.idx;
				if (idx == 1) {
					this.spare_arr[i].file.splice(ins, 1);
					this.spare_arr[i].file_name.splice(ins, 1);
					this.setData({
						[`spare_arr[${i}].file`]: this.spare_arr[i].file,
						[`spare_arr[${i}].file_name`]: this.spare_arr[i].file_name
					});
				} else {
					this.file.splice(i, 1);
					this.file_name.splice(i, 1);
					this.setData({
						file: this.file,
						file_name: this.file_name
					});
				}
			},
			// input显示
			onInput(e) {
				let val = e.detail.value;
				let i = e.currentTarget.dataset.i;
				this.setData({
					[`val[${i}]`]: val
				});
			},
			onItemInp(e) {
				let idx = e.currentTarget.dataset.idx;
				let i = e.currentTarget.dataset.i;
				let val = e.detail.value;
				switch (idx) {
					case 0:
						this.setData({
							[`spare_arr[${i}].spare_parts_name`]: val
						});
						break;
					case 1:
						this.setData({
							[`spare_arr[${i}].number`]: val
						});
						break;
					case 2:
						this.setData({
							[`spare_arr[${i}].piece`]: val
						});
						break;
					case 3:
						this.setData({
							[`spare_arr[${i}].material`]: val
						});
						break;
					case 4:
						this.setData({
							[`spare_arr[${i}].remarks`]: val
						});
						break;
				}
			},
			// 相信信息展示
			onInfoShow() {
				console.log(this.addinfo_show);
				this.setData({
					addinfo_show: !this.addinfo_show
				});
			},
			// 客服弹框显示
			onKfShow() {
				this.setData({
					kf_show: !this.kf_show
				});
			},
			// 开关
			onChange(e) {
				this.setData({
					checked: e.detail
				});
			},
			// 弹框显示
			onArea(e, _dataset) {
				console.log(e.currentTarget.dataset.type);
				console.log(_dataset);
				/* ---处理dataset begin--- */
				this.handleDataset(e, _dataset);
				/* ---处理dataset end--- */
				let i = e.currentTarget.dataset.type;
				let add_idx = e.currentTarget.dataset.i;
				if (i == 4) {
					this.technologyList = this.spare_arr[add_idx].machining_id
				}
				if (i == 2) {
					// this.getLocation()
					const that = this
					uni.getSetting({
						success(res) {
							console.log('获取位置');
							if (!res.authSetting['scope.userLocation']) {
								uni.authorize({
									scope: 'scope.userLocation',
									success() {
										// _this.chooseLoction()
									},
									fail() {
										uni.showModal({
											title: '请求授权当前位置',
											content: '需要获取您的地理位置，请确认授权',
											success(res) {
												if (res.cancel) {
													//用户拒绝授权
													return uni.showToast({
														title: '拒绝授权获取地址信息',
														icon: 'none'
													});
												} else if (res.confirm) {
													uni.openSetting({
														success(res) {
															console.log(res)
															// that.getLocation()
															// that.showYY = true
														},
														fail() {
															console.log(111)
															return uni.showToast({
																title: '拒绝授权获取地址信息',
																icon: 'none'
															});
														}
													})
												}
											}
										})
										that.showTips = false
									}
								})
							} else {
								// _this.chooseLoction()
								// that.getLocation()
								that.showYY = true
							}
						}
					})
				}
				let status = this.show_list[i];
				this.setData({
					[`show_list[${i}]`]: !status,
					act: i,
					add_idx: add_idx
				});
			},
			//  弹框关闭
			onClose() {
				this.showTips = false
				this.setData({
					show_list: [false, false]
				});
			},
			//  弹框确认点击
			confirm(e) {
				switch (this.act) {
					case 0:
						this.setData({
							// [`val[1]`]: util.formatTime(e.detail, "YYYY-MM-DD"),
							[`val[1]`]: e.detail.value
						});
						break;
					case 1:
						console.log(e);
						this.setData({
							[`val[2]`]: e.detail.value.name,
							procurement_area_id: e.detail.value.id
						});
						break;
					case 2:
						console.log(e)
						const name1 = e.detail.values[0].name
						const name2 = e.detail.values[1] && e.detail.values[1].name ? e.detail.values[1].name : ''
						this.setData({
							[`val[3]`]: [name1, name2]
						});
						break;
					case 3:
						this.setData({
							[`val[4]`]: util.formatTime(e.detail, 'YYYY-MM-DD')
						});
						break;
				}
				this.onClose();
			},
			// 弹框确认
			confirmType(e) {
				let i = this.add_idx;
				this.setData({
					[`spare_arr[${i}].machining_id`]: e.detail.value.id,
					[`spare_arr[${i}].machining_name`]: e.detail.value.name
				});
				this.onClose();
			},
			onRadio(e, _dataset) {
				/* ---处理dataset begin--- */
				this.handleDataset(e, _dataset);
				/* ---处理dataset end--- */
				let act = e.currentTarget.dataset.act;
				let i = e.currentTarget.dataset.i;
				console.log(act, i);
				if (act == 1 && i == 4) {
					this.showPopup = true
				}
				this.setData({
					[`radio[${i}]`]: act
				});
				if (i == 3 && act == 1) {
					this.setData({
						[`val[4]`]: ''
					});
				}
			},
			// 获取配置
			getBase() {
				http.request('base/configData').then((res) => {
					this.setData({
						bese_info: res.data
					});
				}).catch((res) => {
					uni.showToast({
						title: res.message,
						icon: 'none'
					});
				});
			},
			// 获取详情
			getInfo() {
				http.request('user/demandInfo', {
					id: this.id
				}).then((res) => {
					this.setData({
						[`val[0]`]: res.data.info.spare_parts_name,
						drawing: res.data.info.drawing,
						file_name: res.data.info.file_name,
						file: res.data.info.file,
						checked: res.data.info.is_secrecy == 1 ? true : false,
						spare_arr: res.data.info.DemandParts,
						[`val[1]`]: res.data.info.end_at,
						[`val[2]`]: res.data.info.procurement_area_name,
						procurement_area_id: res.data.info.procurement_area_id,
						[`val[3][0]`]: res.data.info.province,
						[`val[3][1]`]: res.data.info.city,
						[`radio[0]`]: res.data.info.is_tax_include,
						[`radio[1]`]: res.data.info.is_freight,
						[`radio[2]`]: res.data.info.is_budget,
						[`radio[3]`]: res.data.info.delivery_type,
						[`val[4]`]: res.data.info.delivery_at,
						[`val[5]`]: res.data.info.company,
						[`val[6]`]: res.data.info.username,
						[`val[7]`]: res.data.info.mobile,
						[`val[8]`]: res.data.info.email,
						addinfo_show: true
					});
				}).catch((res) => {
					console.log(res);
				});
			},
			wxAuthLogin() {
				console.log('调用了');
				let that = this;
				uni.login({
					complete: (res) => {
						console.log(res, '--------------------');
						let data = {
							code: res.code
						};
						let h = {
							'content-type': 'application/x-www-form-urlencoded'
						};
						uni.request({
							url: http.appUrl + 'login/getLogin',
							data: data,
							method: 'POST',
							header: h,
							success: (res) => {
								uni.setStorageSync('token', res.data.data.token.token);
								uni.setStorageSync('is_login', res.data.code);
								this.getBase();
								this.getUserInfo();
							},
							fail(res) {
								console.log(res);
							}
						});
					}
				});
			}
		}
	};
</script>
<style>
	@import './subDemand.css';

	.uni-popup {
		position: static !important;
	}

	.popupBox {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.popupImg {
		width: 550rpx;
	}

	.popupOut {
		width: 50rpx;
		height: 50rpx;
		margin-top: 100rpx;
	}

	.xpopupBox {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.xloginPopup {
		width: 550rpx;
		height: 250rpx;
		background-color: #FFF;
		border-radius: 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-evenly;
		align-items: center;
	}

	.xloginPopup>view:first-child {
		color: #000;
		width: 400rpx;
		font-size: 28rpx;
		font-weight: bold;
	}

	.xloginPopup>view:last-child {
		font-size: 30rpx;
		border-radius: 12rpx;
		font-weight: bold;
		color: #FFF;
		padding: 15rpx 170rpx;
		background-color: #01C060;
	}

	.search-D {
		position: absolute;
		/* top: 120%; */
		background: white;
		width: 100%;
		z-index: 12;
		box-shadow: 0 3px 5px 0 rgba(0, 0, 0, .1);
		border-radius: 0 0 10px 10px;
		font-size: 14px;
		display: flex;
		flex-direction: column;
	}

	.titleName {
		line-height: 30px;
		padding: 6px 0 6px 6px;
		border-bottom: 1px solid gainsboro;
	}

	.passed {
		position: relative;
		width: 50rpx;
		height: 50rpx;
		margin-left: 15rpx;
	}
</style>